x86/pv: Introduce and use x86emul_write_dr()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 23 Mar 2018 20:26:34 +0000 (20:26 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 17 Apr 2018 14:12:36 +0000 (15:12 +0100)
commitf539ae27061c6811fd5e80e0755bf0514e22b977
treebfb501910f2ac89f8e81c1864bb67ea03e1bf3c7
parent881f8dc4314809293efc6f66f9af49734994bf0e
x86/pv: Introduce and use x86emul_write_dr()

set_debugreg() has several bugs:

 * %dr4/5 should function correctly as aliases of %dr6/7 when CR4.DE is clear.
 * Attempting to set the upper 32 bits of %dr6/7 should fail with #GP[0]
   rather than be silently corrected and complete.
 * For emulation, the #UD and #GP[0] cases need properly distinguishing.  Use
   -ENODEV for #UD cases, leaving -EINVAL (bad bits) and -EPERM (not allowed to
   use that valid bit) as before for hypercall callers.
 * A write which clears %dr7.L/G leaves the IO shadow intact, meaning that
   subsequent reads of %dr7 will see stale IO watchpoint configuration.

Implement x86emul_write_dr() as a thin wrapper around set_debugreg().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/arch/x86/pv/emul-priv-op.c
xen/arch/x86/traps.c
xen/arch/x86/x86_emulate.c
xen/arch/x86/x86_emulate/x86_emulate.h